package cn.pw.test.com.news.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

public class FragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> fragments;
    private FragmentManager manager;
    private String[] title;

    public FragmentAdapter(FragmentManager fragmentManager, List<Fragment> fragments, String[] title) {
        super(fragmentManager);
        this.fragments = fragments;
        this.manager = fragmentManager;
        this.title = title;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        if (title != null) {
            return title[position];
        }
        return super.getPageTitle(position);
    }

    @Override
    public Fragment getItem(int i) {
        return fragments.get(i);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
